<%-- 
    Document   : QuanLyThanhVien
    Created on : Nov 16, 2012, 10:37:29 PM
    Author     : NGUYEN DANG
--%>


<%@page import="All.DTO.AccountDTO"%>
<%@page import="All.DTO.AccountBean"%>
<%@page import="All.utility.UserManagerProperties"%>
<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="java.util.*"%>

<%
	// Check the seesion and the user's role
        //out.println("bat dau!");
	AccountBean user = (AccountBean) session.getAttribute("UserBean");
	if ((user == null) || (!user.getRole().equals(UserManagerProperties.ADMIN_ROLE))) {
		response.sendRedirect("./DangNhap.jsp");
	}
	ArrayList<AccountDTO> list = (ArrayList) request.getAttribute("userList");
%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>User Management</title>
        <meta name="description" content="website description" />
        <meta name="keywords" content="website keywords, website keywords" />
        <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
        <link rel="stylesheet" type="text/css" href="./css/style.css" />
        <!-- modernizr enables HTML5 elements and feature detects -->
        <script type="text/javascript" src="./js/modernizr-1.5.min.js"></script>
    </head>    
    <body>
        <div id="main">
            <header>
                <jsp:include page="./file/header.jsp"></jsp:include>
            </header>
            <div id="site_content">
                <jsp:include page="./file/LeftMenu.jsp"></jsp:include>
                <div class="content">
                    <form id="contact" action="contact.html" method="post">
                        <div class="form_settings">
                            <h1>The list of users</h1>
                            <table>
                                <tr>
                                        <td>User name</td>
                                        <td>Password</td>
                                        <td>Họ Tên</td>
                                        
                                        <td>Email</td>                                        
                                        
                                        <td>Ngày Tham Gia</td>
                                        <td>Role</td>
                                </tr>
                                <%
                                for (int i=0; i< list.size(); i++) {
                                        AccountDTO userDTO = list.get(i);
                                %>
                                <br><tr>
                                    <td><a href="./ViewUserServlet?username=<%=userDTO.getUsername()%>"><%=userDTO.getUsername()%></a></td>
                                    <td><%=userDTO.getPassword()%></td>
                                    <td><%=userDTO.getHoten()%></td>
                                    
                                    <td><%=userDTO.getEmail()%></td>
                                                                                   
                                    <td><%=userDTO.getNgaythamgia()%></td>
                                    <td><%=userDTO.getRole()%></td>
                                    <td><a href="./DeleteUserServlet?username=<%=userDTO.getUsername()%>">Delete</a></td>
                                
                                        </tr>
                                <%	
                                }
                                %>
                            </table>
                        </div>
                    </form>
                </div>
            </div>           
            <footer>
                <jsp:include page="./file/footer.jsp"></jsp:include>
            </footer>
        </div>
        <p>&nbsp;</p>
  <!-- javascript at the bottom for fast page loading -->
  <script type="text/javascript" src="./js/jquery.js"></script>
  <script type="text/javascript" src="./js/jquery.easing-sooper.js"></script>
  <script type="text/javascript" src="./js/jquery.sooperfish.js"></script>
  <script type="text/javascript" src="./js/image_fade.js"></script>
  <script type="text/javascript">
    $(document).ready(function() {
      $('ul.sf-menu').sooperfish();
    });
  </script>
    </body>
</html>
